<?php include "../ewcfg50.php" ?>
<?php
header('Access-Control-Allow-Origin: *');
//Return: -1 khong hop le.

//Kiem tra toi tai menu
$parent_id = $_POST['pid'];
$sub_id = $_POST['sid'];

$arrParent = array(18=>18,6=>6,7=>7);
$arrKyTu = array(101=>"BR",96=>"CA",97=>"CT",18=>"H",16=>"HD",98=>"HH",19=>"KD",17=>"PL",95=>"TC",99=>"LV",73=>"BH",22=>"BT",21=>"BM",102=>"BV");

if(!isset($arrParent[$parent_id]) || !isset($arrKyTu[$sub_id])){
	echo '-1';
	exit;
}
$char =  $arrKyTu[$sub_id];
//Ket noi co so du lieu
$con = mysql_connect(EW_CONN_HOST,EW_CONN_USER,EW_CONN_PASS);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db(EW_CONN_DB, $con);

$sql = "SELECT mv_id,CONCAT('".$char."',(RIGHT(mv_id,LENGTH(mv_id)-".mb_strlen($char).")+1)) ".
"as top_mv_id FROM movie WHERE parent_id=".$parent_id." AND sub_id=".$sub_id." ORDER BY id DESC LIMIT 1";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
{
  echo $row['top_mv_id'];
}

mysql_close($con);